﻿#pragma once

#include "common.h"
#include "base.h"
#include <vector>

namespace anip
{
	class Shape;
	class Shader;

	namespace vg
	{
		class Stroke : public Primitive
		{
			serializable_id(Stroke, 0x5E62440);

		public:
			enum class CapStyle
			{
				Rounded,
				Box,
				Arrow
			};

			struct Point
			{
				vec2 position = { 0, 0 };
				vec2 normal = { 0, 0 }; 
				color color = { 0, 0, 0, 1 };
				float width = 0.05f;
				// negative: starting or ending point
				float pressure = 0.5f;
				float velocity = 1.0f;
			};

		private:
			class Renderer;

		public:
			static bool RenderDebug;

			std::vector<Point> points;

			bool enclosed = false;
			CapStyle headStyle = CapStyle::Rounded, 
				tailStyle = CapStyle::Rounded;

			Stroke() {}
			Stroke(const Stroke& obj) = delete;

			void calcNormal();

			bool isInside(invec2 p, float time) override;
			GraphicsRenderer* createRenderer() override;
		};
	}
}